﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MBSBusinessEntities;
using System.Transactions;
using MBSVO;
namespace MBSBLC
{
    public partial class BLC
    {
        #region Movie

        MovieBE moviebe;

        public bool AddMovie(string movieTitle, string Description, string Duration, string Genre, string Cast, string Rating, string ImageURL, DateTime ReleaseDate)
        {
            MovieBE moviebe = new MovieBE(movieTitle, Description, Convert.ToInt32(Duration), Genre, Cast, float.Parse(Rating), ImageURL, ReleaseDate);


            return moviebe.Add();

        }

        public bool UpdateMovie(string movieID, string movieTitle, string Description, string Duration, string Genre, string Cast, string Rating, string ImageURL, DateTime ReleaseDate)
        {
            MovieBE moviebe = new MovieBE();
            moviebe = moviebe.GetMovieByID(Convert.ToInt32(movieID));
            moviebe.MovieTitle = movieTitle;
            moviebe.Description = Description;
            moviebe.Duration = Convert.ToInt32(Duration);
            moviebe.Genre = Genre;
            moviebe.Cast = Cast;
            moviebe.Rating = float.Parse(Rating);
            moviebe.ImageURL = ImageURL;
            moviebe.ReleaseDate = ReleaseDate;

            return moviebe.Update();

        }

        public bool DeleteMovie(int MovieID)
        {
            moviebe = new MovieBE();

            return moviebe.Delete(MovieID);


        }

        public MovieVO GetMovieIDByImageUrl(string ImageURL)
        {
            moviebe = new MovieBE();
            moviebe = moviebe.GetMovieByID(moviebe.GetMovieIDByImageUrl(ImageURL));
            MovieVO movieVO = BLCUtility.convertMovieBEtoVO(moviebe);
            return movieVO;
        }

        public MovieVO GetMovieByID(int MovieID)
        {
            moviebe = new MovieBE();
            moviebe = moviebe.GetMovieByID(MovieID);
            MovieVO movieVO = BLCUtility.convertMovieBEtoVO(moviebe);
            return movieVO;
        }

        /*
        public string MovieID(int MovieID) { GetMovieByID(MovieID); return moviebe.MovieID.ToString(); }
        public string MovieTitle(int MovieID) { GetMovieByID(MovieID); return moviebe.MovieTitle.ToString(); }
        public string Description(int MovieID) { GetMovieByID(MovieID); return moviebe.Description.ToString(); }
        public string Duration(int MovieID) { GetMovieByID(MovieID); return moviebe.Duration.ToString(); }
        public string Genre(int MovieID) { GetMovieByID(MovieID); return moviebe.Genre.ToString(); }
        public string Cast(int MovieID) { GetMovieByID(MovieID); return moviebe.Cast.ToString(); }
        public string Rating(int MovieID) { GetMovieByID(MovieID); return moviebe.Rating.ToString(); }
        public string ImageURL(int MovieID) { GetMovieByID(MovieID); return moviebe.ImageURL.ToString(); }
        public string ReleaseDate(int MovieID) { GetMovieByID(MovieID); return moviebe.ReleaseDate.ToString(); }
        public string MovieIsDeleted(int MovieID) { GetMovieByID(MovieID); return moviebe.IsDeleted.ToString(); }
        */

        public Dictionary<int, string> GetAllMovies()
        {

            MovieBE movieBE = new MovieBE();

            List<MovieBE> movieBEList = movieBE.GetAllMovies();

            Dictionary<int, string> movieDictionary = new Dictionary<int, string>();

            foreach (MovieBE movieBETemp in movieBEList)
            {
                movieDictionary.Add(movieBETemp.MovieID, movieBETemp.MovieTitle);

            }

            return movieDictionary;

        }

        public Dictionary<int, string> GetAllMoviesBasedOnCinemaToDisplay(int CinemaID)
        {

            MovieBE movieBE = new MovieBE();

            List<MovieBE> movieBEList = movieBE.GetAllMoviesBasedOnCinemaToDisplay(CinemaID);

            Dictionary<int, string> movieDictionary = new Dictionary<int, string>();

            foreach (MovieBE movieBETemp in movieBEList)
            {
                movieDictionary.Add(movieBETemp.MovieID, movieBETemp.MovieTitle);

            }

            return movieDictionary;

        }

        #endregion
    }
}
